<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鼠标跟随小窗口</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        .mouse-window {
            position: absolute;
            width: 200px;
            height: 100px;
            background-color: #fff;
            border: 1px solid #ccc;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            user-select: none;
            pointer-events: none;
        }
        .window-content {
            padding: 1rem;
            border-radius: 5px;
            background-color: #fff;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body>
    <div class="mouse-window" id="mouseWindow">
        <div class="window-content">
            <p>鼠标跟随小窗口内容</p>
        </div>
    </div>
    <script>
        const mouseWindow = document.getElementById('mouseWindow');
        const windowContent = document.querySelector('.window-content');

        document.addEventListener('mousemove', (e) => {
            mouseWindow.style.left = e.clientX + 'px';
            mouseWindow.style.top = e.clientY + 'px';

            const windowWidth = window.innerWidth;
            const windowHeight = window.innerHeight;

            if (e.clientX < windowWidth / 2) {
                mouseWindow.style.transform = 'translateX(-100%)';
            } else {
                mouseWindow.style.transform = 'translateX(100%)';
            }

            if (e.clientY < windowHeight / 2) {
                mouseWindow.style.transform = 'translateY(-100%)';
            } else {
                mouseWindow.style.transform = 'translateY(100%)';
            }
        });
    </script>
</body>
</html>
